package com.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.TextureView;

public class CustomSizeTextureView extends TextureView {

    private int customWidth = 0;
    private int customHeight = 0;

    public CustomSizeTextureView(Context context) {
        super(context);
    }

    public CustomSizeTextureView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomSizeTextureView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (customWidth > 0 && customHeight > 0) {
            setMeasuredDimension(customWidth, customHeight);
        } else {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    }

    public void setCustomWidth(int customWidth) {
        this.customWidth = customWidth;
    }

    public void setCustomHeight(int customHeight) {
        this.customHeight = customHeight;
    }

}
